package br.com.gecandango.service.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import br.com.gecandango.beans.Atividade;
import br.com.gecandango.beans.Evento;
import br.com.gecandango.beans.Programacao;
import br.com.gecandango.service.EventoService;

public class EventoServiceImpl extends HibernateDaoSupport implements
	EventoService {
	public void save(Evento bean) {
		getHibernateTemplate().saveOrUpdate(bean);
	}
	public List<Evento> list() {
		return getHibernateTemplate().find("from Evento");
	}
	public Evento find(Long id) {
		List<Evento> e = (List<Evento>)getHibernateTemplate().find("from Evento where id=?", id);
		return e.get(0);
	}
	
	public void delete(Evento bean) {
		getHibernateTemplate().delete(bean);
	}
	public List<Programacao> getProgramacao(Evento bean) {
		return (List<Programacao>)getHibernateTemplate().find("from Programacao where id_evento=?", bean.getId());
	}
	public void addProgramacao(Programacao bean) {
		getHibernateTemplate().saveOrUpdate(bean);
	}
	public void addAtividade(Atividade bean) {
		getHibernateTemplate().saveOrUpdate(bean);
	}
}
